﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
 
namespace Solidi
{
	public class DependencyGroup
	{
		private object _locker = new object();
		private IDependency[] _dependencies = new IDependency[0];

		public void Add(IDependency dependency)
		{
			lock (_locker)
			{
				List<IDependency> dependencies = new List<IDependency>(_dependencies);

				dependencies.Add(dependency);

				_dependencies = dependencies.ToArray();
			}
		}

		public void Remove(IDependency dependency)
		{
			lock (_locker)
			{
				List<IDependency> dependencies = new List<IDependency>(_dependencies);

				dependencies.Remove(dependency);

				_dependencies = dependencies.ToArray();
			}
		}

		public IDependency[] Dependencies
		{
			get
			{
				return _dependencies;
			}
		}
	}
}
